import { getRgbValue, alpha } from 'bee/utils/color';
import { colors } from 'bee/themes';
import { px2dp } from 'bee/utils/px2dp';
import noop from 'bee/utils/noop';

/**
 *
 * @param {Array} data 选择器数据
 * @param {Function} onPickerConfirm 点击确定回调函数
 * @param {object} restParams 其余参数
 *
 * @returns {any} 选择器属性配置
 */
function pickerOptions(data, onPickerConfirm, restParams) {
  return {
    pickerData: data,
    onPickerConfirm,
    pickerTitleText: (restParams && restParams.pickerTitleText) || '',
    pickerConfirmBtnText:
      (restParams && restParams.pickerConfirmBtnText) || '确定',
    pickerCancelBtnText:
      (restParams && restParams.pickerCancelBtnText) || '取消',
    pickerConfirmBtnColor: getRgbValue(
      (restParams && restParams.pickerConfirmBtnColor) || '#007AFF'
    ),
    pickerCancelBtnColor: getRgbValue(
      (restParams && restParams.pickerCancelBtnColor) || '#007AFF'
    ),
    pickerToolBarBg: getRgbValue(
      (restParams && restParams.pickerToolBarBg) || '#f6f6f6'
    ),
    pickerBg: getRgbValue(
      (restParams && restParams.pickerBg) || alpha(colors.white)
    ),
    pickerRowHeight: px2dp((restParams && restParams.pickerRowHeight) || 70),
    pickerFontSize: px2dp((restParams && restParams.pickerFontSize) || 34),
    selectedValue: (restParams && restParams.selectedValue) || [],
    onPickerCancel: (restParams && restParams.onPickerCancel) || noop,
    onPickerSelect: (restParams && restParams.onPickerSelect) || noop,
  };
}

export default pickerOptions;
